package com.ruoyi.authorize.controller;

import com.ruoyi.authorize.service.AuthorizeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 授权、登录校验相关接口
 */
@RestController
@RequestMapping("/authorize")
@Slf4j
public class AuthorizeController extends BaseController {

    @Autowired
    private AuthorizeService authorizeService;

    /**
     * 发送短信验证码
     */
    @PostMapping("/sendTextCode")
    public AjaxResult sendTextCode(@RequestBody LoginBody loginBody) {
        log.info("发送验证码 开始");
        AjaxResult ajaxResult = authorizeService.sendTextCode(loginBody);
        log.info("发送验证码 结束");
        return ajaxResult;
    }

    /**
     * 校验短信验证码
     */
    @PostMapping("/checkTextCode")
    public AjaxResult checkTextCode(@RequestBody LoginBody loginBody) {
        log.info("校验短信验证码 开始");
        AjaxResult ajaxResult = authorizeService.checkTextCode(loginBody);
        log.info("校验短信验证码 结束");
        return ajaxResult;
    }

}
